﻿using Corina.Datamodel.Entities;
using Corina.Enumerations;
using Corina.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Corina.Datamodel.DataObject
{
    [XmlInclude(typeof(DataObjectInfo))]
    [XmlInclude(typeof(ObjectValueInfo))]
    [XmlTypeAttribute(Namespace = "http://tempuri.org/")]
    public class ResultInfo : BaseClass
    {
        public ResultInfo() { }

        public ResultInfo(ResultValue result, params DatamodelEntity[] paras)
        {
            Result = result;
            Entities.AddRange(paras);
        }

        #region Fields
        private ResultValue _result = ResultValue.Unknown;
        private string _description = string.Empty;
        private List<DatamodelEntity> _entities = new List<DatamodelEntity>();
        private List<DataObjectInfo> _dataObjects = new List<DataObjectInfo>();
        private int _totalCount = 0;
        #endregion

        #region Properties
        public ResultValue Result
        {
            get { return _result; }
            set
            {
                _result = value;
                RaisePropertyChanged(() => Result);
            }
        }

        public string Description
        {
            get { return _description; }
            set
            {
                _description = value;
                RaisePropertyChanged(() => Description);
            }
        }

        public List<DatamodelEntity> Entities
        {
            get { return _entities; }
            set
            {
                _entities = value;
                RaisePropertyChanged(() => Entities);
            }
        }

        public List<DataObjectInfo> DataObjects
        {
            get { return _dataObjects; }
            set
            {
                _dataObjects = value;
                RaisePropertyChanged(() => DataObjects);
            }
        }

        public int TotalCount
        {
            get { return _totalCount; }
            set
            {
                _totalCount = value;
                RaisePropertyChanged(() => TotalCount);
            }
        }
        #endregion

        public void Insert(params DatamodelEntity[] paras)
        {
            Entities.AddRange(paras);
        }
    }
}
